package com.example.stock.business.monitor.logic;

import com.example.stock.excel.Monitor;
import com.example.stock.model.WeekDetail;
import com.example.stock.service.WeekDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * PB 大于指定值
 */
@Component
public class PBIncreaseMonitor implements Trigger{

    @Autowired
    WeekDataService weekDataService;

    @Override
    public boolean trigger(Monitor monitor) {
        WeekDetail currentWeekDetail = weekDataService.getCurrentWeekDetail(monitor.getStock());
        if (Objects.isNull(currentWeekDetail)) {
            return false;
        }
        return currentWeekDetail.getPbRatio() >= Double.parseDouble(monitor.getExtra()) ;
    }
}
